package com.etc.colldemo;

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.*;

/**
 * @author: knowno
 * @create: 2024-09-10 10:52
 * @Version 1.0
 **/
public class TestLinkedList {
    public static void main(String[] args) {
        // Collection ->List ->AbstractList => AbstractSequentialList ->LinkedList->常见的类，属性和方法
//        public class LinkedList<E>
//                extends AbstractSequentialList<E>
//                implements List<E>, Deque<E>, Cloneable, java.io.Serializable


        //1 构造
        LinkedList<Object> objects = new LinkedList<>();
        //2 属性和方法
        objects.add(1);
        objects.add("abc");
        objects.add(new Object());

        //独有的方法
        objects.addFirst(LocalDate.now());
        objects.addLast(LocalTime.now());

        //其他方法.......
        //3 从collection继承了啥？实现了哪些方法? 遍历？iterator迭代？
        System.out.println("*********objects.forEach jdk1.8 *****************");
        objects.forEach(System.out::println);
        System.out.println("*********for*****************");
        for (int i = 0; i <objects.size() ; i++) {
            System.out.println(objects.get(i));
        }
        System.out.println("*********foreach*****************");
        for (Object obj:objects) {
            System.out.println(obj);
        }
        System.out.println("***********iterator***************");
        Iterator<Object> iterator = objects.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }

    }
}
